#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n1,n2;
    int n;
    cin>>n1>>n2>>n;
    int p1=n1,p2=n2;
    for (int i=0;i<n;i++)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int sum=a+c;
        if (b==sum&&d!=sum)
            n1--;
        else if (d==sum&&b!=sum)
            n2--;
        if (n1==-1)
        {
            cout<<'A'<<endl<<p2-n2;
            return 0;
        }
        else if (n2==-1)
        {
            cout<<'B'<<endl<<p1-n1;
            return 0;
        }
    }
}